// Transaction.cpp: implementation of the Transaction class.
//
//////////////////////////////////////////////////////////////////////
#pragma warning(disable:4530)
#pragma warning(disable:4786)
#define WIN32_LEAN_AND_MEAN

#include "Transaction.h"
#include "SIPMessage.h"

#ifdef USE_DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
// SIPTransaction.cpp: implementation of the CTransaction class.
//
//////////////////////////////////////////////////////////////////////


int CTransaction::m_T1 = 500;
int CTransaction::m_T2 = 4000;//4 seconds
int	CTransaction::m_T4 = 5000;//5 seconds
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CTransaction::CTransaction(const char *ptid,CSIPStack *pstack,bool client)
{
	if(ptid)
		m_sTransactionID = ptid;
	else
		m_sTransactionID = "";
	m_pStack = pstack;
	m_bClient = client;
	m_nTries = 0;
	m_nTimerB = 64*m_T1;
	m_nStartTime = 0;
	m_pSendingMsg = NULL;
	m_pRequestMsg = NULL;
	m_pResponseMsg = NULL;
    m_bNeedBySendProc = false;
}

CTransaction::~CTransaction()
{
	if(m_pSendingMsg)
	{
		delete m_pSendingMsg;
		m_pSendingMsg = NULL;
	}
	if(m_pRequestMsg)
	{
		delete m_pRequestMsg;
		m_pRequestMsg = NULL;
	}
	if(m_pResponseMsg)
	{
		delete m_pResponseMsg;
		m_pResponseMsg = NULL;
	}	
}

bool CTransaction::IsMatching(CSIPMessage *pmsg)
{
	/*
	if(pmsg->GetCallId()->GetCallId() != m_strCallID)
		return false;
	if(m_nCSeq != pmsg->GetSequence()->GetSequence())
		return false;
	if(m_strFromTag != pmsg->GetFrom()->GetParamValue("tag"))
		return false;
	if(pmsg->GetTo()->FindParam("tag"))
	{
		if(m_strToTag != pmsg->GetTo()->GetParamValue("tag"))
			return false;
	}
	else
	{
		if(m_strToTag.empty() == false)
			return false;
	}
	if(*pmsg->GetVias().front() != m_TopVia)
		return false;
	*/		
	return true;
}
